/**
 * Copyright (C) 2012 The SkyTvOS Project
 *
 * Version     Date           Author
 * ─────────────────────────────────────
 *           2016-3-25         yellowlgx
 *
 */

package com.skyworth.ui.listview;

import android.util.SparseArray;

/**
 * @ClassName ItemTypeUtil
 * @Description TODO (write something)
 * @author yellowlgx
 * @date 2016-3-25
 * @version TODO (write something)
 */
public class ItemTypeUtil
{
    /**
     * [int,obj]
     * 
     * int : 最终的type obj : 传入的type
     */
    private SparseArray<Object> typeSArr = new SparseArray<Object>();

    /**
     * @param type
     *            item的类型
     * 
     * @return 通过object类型的type来得到int类型的type
     */
    public int getIntType(Object type)
    {
        int index = typeSArr.indexOfValue(type);
        if (index == -1)
        {
            index = typeSArr.size();
            // 如果没用这个type，就存入这个type
            typeSArr.put(index, type);
        }
        return index;
    }
}
